Start moving geocache data to a class. It's complicated.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 8 Feb 2013 07:06:48 +0000 (07:06 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 8 Feb 2013 07:06:48 +0000 (07:06 +0000)
gpsbabel/defs.h
gpsbabel/waypt.cc

index 962765288c4e6ef1c8de2c412e423729d84195d9..4c4abbea59721f16926225b4152dc5c0e30d4ae6 100644 (file)
@@ -272,7 +272,24 @@ class utf_string{
   char* utfstring;
 };
 
-typedef struct {
+class geocache_data {
+ public:
+  geocache_data() :
+    id(0),
+    type(gt_unknown),
+    container(gc_unknown),
+    diff(0),
+    terr(0),
+    is_archived(status_unknown),
+    is_available(status_unknown),
+    is_memberonly(status_unknown),
+    has_customcoords(status_unknown),
+    placer(NULL),
+    placer_id(0),
+    hint(NULL),
+    favorite_points(0),
+    personal_note(NULL)
+  {}
   int id; /* The decimal cache number */
   geocache_type type:5;
   geocache_container container:4;
@@ -291,7 +308,7 @@ typedef struct {
   utf_string desc_long;
   int favorite_points;
   char* personal_note;
-} geocache_data ;
+};
 
 typedef struct xml_tag {
   char* tagname;
@@ -563,7 +580,7 @@ public:
   float power; /* watts, as measured by cyclists */
   float temperature; /* Degrees celsius */
   float odometer_distance; /* Meters? */
-  const geocache_data* gc_data;
+  geocache_data* gc_data;
   format_specific_data* fs;
   session_t* session;  /* pointer to a session struct */
   void* extra_data;    /* Extra data added by, say, a filter. */
index 7abe4c37a17ea27fd9af444d0d148880f6c46236..9393f3f1bfd395c4f6f92bf73e4fe22ba1a727fb 100644 (file)
@@ -29,7 +29,7 @@
 queue waypt_head;
 static unsigned int waypt_ct;
 static short_handle mkshort_handle;
-static geocache_data empty_gc_data = { 0 };
+static geocache_data empty_gc_data;
 static global_trait traits;
 
 const global_trait* get_traits(void)
@@ -82,7 +82,7 @@ waypt_dupe(const waypoint *wpt)
 
   if (wpt->gc_data != &empty_gc_data) {
     geocache_data *gc_data = (geocache_data*) xmalloc(sizeof(*gc_data));
-    tmp->gc_data = (const geocache_data *)gc_data;
+    tmp->gc_data = (geocache_data *)gc_data;
 
     memcpy(gc_data, wpt->gc_data, sizeof(*gc_data));
     if (wpt->gc_data->desc_short.utfstring) {
@@ -680,7 +680,7 @@ waypt_alloc_gc_data(waypoint *wpt)
   geocache_data *res = (geocache_data *)wpt->gc_data;
   if (res == &empty_gc_data) {
     res = (geocache_data*) xcalloc(1, sizeof(*res));
-    wpt->gc_data = (const geocache_data *)res;
+    wpt->gc_data = (geocache_data *)res;
 
   }
   return res;